package com.it.data_tree.tree.binaryTree;

/**
 * @Author: Coke
 * @Description: 判断是否为对称二叉树
 * @DateTime: 2023/4/13 23:03
 **/
public class SymmetricBinaryTree {

    /**
     * @作者: Coke
     * @注释: 判断是否为对称二叉树
     * @DateTime: 2023/4/14 19:29
     *
     * @param left:
     * @param right:
     * @return boolean
     */
    public static boolean isSymmetric(Node left, Node right) {
        if (left == null && right == null) {
            return true;
        }
        if (left == null || right == null){
            return false;
        }
        if (left.getNo() != right.getNo()){
            return false;
        }
        return isSymmetric(left.getLeft(), right.getRight()) && isSymmetric(left.getRight(), right.getLeft());
    }
}
